<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/limh/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/limh/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/limh/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/limh/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/limh/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/limh/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/limh/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="教程,">










<meta name="description" content="简介string .h 头文件定义了一个变量类型、一个宏和各种操作字符数组的函数。 库变量下面是头文件 string.h 中定义的变量类型：    序号 变量 &amp;amp; 描述     1 size_t  这是无符号整数类型，它是 sizeof 关键字的结果。    库宏下面是头文件 string.h 中定义的宏：    序号 宏 &amp;amp; 描述     1 NULL  这个宏是一个空指针常量的">
<meta name="keywords" content="教程">
<meta property="og:type" content="article">
<meta property="og:title" content="string.h">
<meta property="og:url" content="https://tdnr.gitee.io/limh/2015/03/14/cfunc14/index.html">
<meta property="og:site_name" content="土逗牛肉">
<meta property="og:description" content="简介string .h 头文件定义了一个变量类型、一个宏和各种操作字符数组的函数。 库变量下面是头文件 string.h 中定义的变量类型：    序号 变量 &amp;amp; 描述     1 size_t  这是无符号整数类型，它是 sizeof 关键字的结果。    库宏下面是头文件 string.h 中定义的宏：    序号 宏 &amp;amp; 描述     1 NULL  这个宏是一个空指针常量的">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-01-20T03:19:25.986Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="string.h">
<meta name="twitter:description" content="简介string .h 头文件定义了一个变量类型、一个宏和各种操作字符数组的函数。 库变量下面是头文件 string.h 中定义的变量类型：    序号 变量 &amp;amp; 描述     1 size_t  这是无符号整数类型，它是 sizeof 关键字的结果。    库宏下面是头文件 string.h 中定义的宏：    序号 宏 &amp;amp; 描述     1 NULL  这个宏是一个空指针常量的">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/limh/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://tdnr.gitee.io/limh/2015/03/14/cfunc14/">





  <title>string.h | 土逗牛肉</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans ">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/limh/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">土逗牛肉</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/limh/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/limh/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/limh/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/limh/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/limh/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://tdnr.gitee.io/limh/limh/2015/03/14/cfunc14/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="土逗牛肉">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/limh/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="土逗牛肉">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">string.h</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-03-14T20:35:45+08:00">
                2015-03-14
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/limh/categories/C函数库/" itemprop="url" rel="index">
                    <span itemprop="name">C函数库</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>string .h 头文件定义了一个变量类型、一个宏和各种操作字符数组的函数。</p>
<h2 id="库变量"><a href="#库变量" class="headerlink" title="库变量"></a>库变量</h2><p>下面是头文件 string.h 中定义的变量类型：</p>
<table>
<thead>
<tr>
<th>序号</th>
<th>变量 &amp; 描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><strong>size_t</strong> <br> 这是无符号整数类型，它是 sizeof 关键字的结果。</td>
</tr>
</tbody>
</table>
<h2 id="库宏"><a href="#库宏" class="headerlink" title="库宏"></a>库宏</h2><p>下面是头文件 string.h 中定义的宏：</p>
<table>
<thead>
<tr>
<th>序号</th>
<th>宏 &amp; 描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><strong>NULL</strong> <br> 这个宏是一个空指针常量的值。</td>
</tr>
</tbody>
</table>
<h2 id="库函数"><a href="#库函数" class="headerlink" title="库函数"></a>库函数</h2><p>下面是头文件 string.h 中定义的函数：</p>
<table>
<thead>
<tr>
<th>序号</th>
<th>函数 &amp; 描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td><strong>void &#42;memchr(const void &#42;str, int c, size_t n)</strong> <br> 在参数 str 所指向的字符串的前 n 个字节中搜索第一次出现字符 c（一个无符号字符）的位置。</td>
</tr>
<tr>
<td>2</td>
<td><strong>int memcmp(const void &#42;str1, const void &#42;str2, size_t n)</strong> <br> 把 str1 和 str2 的前 n 个字节进行比较。</td>
</tr>
<tr>
<td>3</td>
<td><strong>void &#42;memcpy(void &#42;dest, const void &#42;src, size_t n)</strong> <br> 从 src 复制 n 个字符到 dest。</td>
</tr>
<tr>
<td>4</td>
<td><strong>void &#42;memmove(void &#42;dest, const void &#42;src, size_t n)</strong> <br> 另一个用于从 str2 复制 n 个字符到 str1 的函数。</td>
</tr>
<tr>
<td>5</td>
<td><strong>void &#42;memset(void &#42;str, int c, size_t n)</strong> <br> 复制字符 c（一个无符号字符）到参数 str 所指向的字符串的前 n 个字符。</td>
</tr>
<tr>
<td>6</td>
<td><strong>char &#42;strcat(char &#42;dest, const char &#42;src)</strong> <br> 把 src 所指向的字符串追加到 dest 所指向的字符串的结尾。</td>
</tr>
<tr>
<td>7</td>
<td><strong>char &#42;strncat(char &#42;dest, const char &#42;src, size_t n)</strong> <br> 把 src 所指向的字符串追加到 dest 所指向的字符串的结尾，直到 n 字符长度为止。</td>
</tr>
<tr>
<td>8</td>
<td><strong>char &#42;strchr(const char &#42;str, int c)</strong> <br> 在参数 str 所指向的字符串中搜索第一次出现字符 c（一个无符号字符）的位置。</td>
</tr>
<tr>
<td>9</td>
<td><strong>int strcmp(const char &#42;str1, const char &#42;str2)</strong> <br> 把 str1 所指向的字符串和 str2 所指向的字符串进行比较。</td>
</tr>
<tr>
<td>10</td>
<td><strong>int strncmp(const char &#42;str1, const char &#42;str2, size_t n)</strong> <br> 把 str1 和 str2 进行比较，最多比较前 n 个字节。</td>
</tr>
<tr>
<td>11</td>
<td><strong>int strcoll(const char &#42;str1, const char &#42;str2)</strong> <br> 把 str1 和 str2 进行比较，结果取决于 LC_COLLATE 的位置设置。</td>
</tr>
<tr>
<td>12</td>
<td><strong>char &#42;strcpy(char &#42;dest, const char &#42;src)</strong> <br> 把 src 所指向的字符串复制到 dest。</td>
</tr>
<tr>
<td>13</td>
<td><strong>char &#42;strncpy(char &#42;dest, const char &#42;src, size_t n)</strong> <br> 把 src 所指向的字符串复制到 dest，最多复制 n 个字符。</td>
</tr>
<tr>
<td>14</td>
<td><strong>size_t strcspn(const char &#42;str1, const char &#42;str2)</strong> <br> 检索字符串 str1 开头连续有几个字符都不含字符串 str2 中的字符。</td>
</tr>
<tr>
<td>15</td>
<td><strong>char &#42;strerror(int errnum)</strong> <br> 从内部数组中搜索错误号 errnum，并返回一个指向错误消息字符串的指针。</td>
</tr>
<tr>
<td>16</td>
<td><strong>size_t strlen(const char &#42;str)</strong> <br> 计算字符串 str 的长度，直到空结束字符，但不包括空结束字符。</td>
</tr>
<tr>
<td>17</td>
<td><strong>char &#42;strpbrk(const char &#42;str1, const char &#42;str2)</strong> <br> 检索字符串 str1 中第一个匹配字符串 str2 中字符的字符，不包含空结束字符。也就是说，依次检验字符串 str1 中的字符，当被检验字符在字符串 str2 中也包含时，则停止检验，并返回该字符位置。</td>
</tr>
<tr>
<td>18</td>
<td><strong>char &#42;strrchr(const char &#42;str, int c)</strong> <br> 在参数 str 所指向的字符串中搜索最后一次出现字符 c（一个无符号字符）的位置。</td>
</tr>
<tr>
<td>19</td>
<td><strong>size_t strspn(const char &#42;str1, const char &#42;str2)</strong> <br> 检索字符串 str1 中第一个不在字符串 str2 中出现的字符下标。</td>
</tr>
<tr>
<td>20</td>
<td><strong>char &#42;strstr(const char &#42;haystack, const char &#42;needle)</strong> <br> 在字符串 haystack 中查找第一次出现字符串 needle（不包含空结束字符）的位置。</td>
</tr>
<tr>
<td>21</td>
<td><strong>char &#42;strtok(char &#42;str, const char &#42;delim)</strong> <br> 分解字符串 str 为一组字符串，delim 为分隔符。</td>
</tr>
<tr>
<td>22</td>
<td><strong>size_t strxfrm(char &#42;dest, const char &#42;src, size_t n)</strong> <br> 根据程序当前的区域选项中的 LC_COLLATE 来转换字符串 src 的前 n 个字符，并把它们放置在字符串 dest 中。</td>
</tr>
</tbody>
</table>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/limh/tags/教程/" rel="tag"># 教程</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/limh/2015/03/13/cfunc13/" rel="next" title="stdlib.h">
                <i class="fa fa-chevron-left"></i> stdlib.h
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/limh/2015/03/15/cfunc15/" rel="prev" title="time.h">
                time.h <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="SOHUCS"></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/limh/images/avatar.jpg" alt="土逗牛肉">
            
              <p class="site-author-name" itemprop="name">土逗牛肉</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/limh/archives/">
              
                  <span class="site-state-item-count">255</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/limh/categories/index.html">
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/limh/tags/index.html">
                  <span class="site-state-item-count">7</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/limhGeek" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:1591054297@qq.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.jianshu.com/u/f73b243e7cc9" target="_blank" title="简书">
                      
                        <i class="fa fa-fw fa-user-circle-o"></i>简书</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#简介"><span class="nav-number">1.</span> <span class="nav-text">简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#库变量"><span class="nav-number">2.</span> <span class="nav-text">库变量</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#库宏"><span class="nav-number">3.</span> <span class="nav-text">库宏</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#库函数"><span class="nav-number">4.</span> <span class="nav-text">库函数</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">土逗牛肉</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
	var str = GetUrlParam('height');
    if (str === '0'){
		document.getElementById('header').style.display = 'none';
		document.getElementById('comments').style.display = 'none';
		document.getElementById('footer').style.display = 'none';
		document.getElementsByClassName('post-footer').item(0).style.display = 'none'
	}
	
    function GetUrlParam(paraName) {
        var url = document.location.toString();
        var arrObj = url.split("?");

        if (arrObj.length > 1) {
            var arrPara = arrObj[1].split("&");
            var arr;

            for (var i = 0; i < arrPara.length; i++) {
                 arr = arrPara[i].split("=");

                if (arr != null && arr[0] === paraName) {
                    return arr[1];
                }
            }
            return "";
        } else {
            return "";
        }
    }
</script>









  












  
  
    <script type="text/javascript" src="/limh/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/limh/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/limh/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/limh/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/limh/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/limh/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/limh/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/limh/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
